<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        table {
            width: 500px;
            margin: 100px auto;
            border-collapse: collapse;
            text-align: center;
        }
        
        td,
        th {
            border: 1px solid #333;
        }
        
        thead tr {
            height: 40px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <table cellspacing="0">
        <thead>
            <tr>
                <th>姓名</th>
                <th>科目</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
    <script>
        // 1.先去准备好学生的数据
        var datas = [{
            name: '魏璎珞',
            subject: 'JavaScript',
            score: 100
        }, {
            name: '弘历',
            subject: 'JavaScript',
            score: 98
        }, {
            name: '傅恒',
            subject: 'JavaScript',
            score: 99
        }, {
            name: '明玉',
            subject: 'JavaScript',
            score: 88
        }, {
            name: '大猪蹄子',
            subject: 'JavaScript',
            score: 0
        }];
        let nodeTbody = document.querySelector('tbody');
        for (let i = 0; i < datas.length; i++) {
            let nodeTr = document.createElement('tr');
            for (let key in datas[i]) {
                let nodeTd = document.createElement('td');
                nodeTd.innerHTML = datas[i][key];
                nodeTr.appendChild(nodeTd);
            }
            let nodeTd = document.createElement('td');
            nodeTd.innerHTML = '<a href ="javascript:;">删除</a>';
            let nodeA = nodeTd.querySelector('a');
            nodeA.onclick = function() {
                nodeTbody.removeChild(nodeTr);
            };
            nodeTr.appendChild(nodeTd);
            nodeTbody.appendChild(nodeTr);
        }
    </script>
</body>

</html>